<?php

	define( 'MAIN_DIR', dirname( __FILE__ ) . DIRECTORY_SEPARATOR );
	
	$USEDB = false;
	include( MAIN_DIR . 'include' . DIRECTORY_SEPARATOR . 'base.inc.php' );
	
	$filename = pathinfo( ( isset( $_GET['filename'] ) && $_GET['filename'] ? ( $_GET['filename'] ) : '' ), PATHINFO_BASENAME );
	if( file_exists( UPLOADS_DIR . toFS( $filename ) ) )	{
		header( 'Pragma: public' );
		header( 'Expires: 0' );
		header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' );
		header( 'Cache-Control: private', false );
		header( 'Content-Type: application/x-download' );
		header( 'Content-Disposition: attachment; filename="' . toHTML ( $filename, FALSE ) . '";' );
		header( 'Content-Transfer-Encoding: binary' );
		
		header( 'Content-Length: '. @filesize( UPLOADS_DIR . toFS( $filename ) ) );
		
		@readfile( UPLOADS_DIR . toFS( $filename ) ) or die( 'File not found.' );
	}
	else
		header( 'HTTP/1.0 404 Not Found' );
